<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
namespace Agp\CoreBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Agp\CoreBundle\Validator\Constraints as AgpAssert;
use Bondcs\Rede\Authorization;

/**
 * Description of Cartao
 *
 * @author bondcs
 * @ORM\Table(name="cartao")
 * @ORM\Entity(repositoryClass="Agp\CoreBundle\Repository\CartaoRepository")
 * @ORM\HasLifecycleCallbacks
 * 
 */
class Cartao {
    
    /**
     * @var integer $id
     *
     * @ORM\Column(name="cod_cartao", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    protected $codCartao;
    
    /**
     * 
     * @ORM\Column(name="nm_cartao", type="string", length=255, nullable=false)
     * @Assert\NotBlank()
     * @AgpAssert\SomenteNumero()
     * @Assert\Length(
     *      min = "6",
     *      max = "19"
     * )
     */
    private $nmCartao;
    
    /**
     *
     * @ORM\Column(type="string", length=80, nullable=false)
     * @Assert\NotBlank()
     * @Assert\Length(
     *      min = "1",
     *      max = "50"
     * )
     */
    private $titular;
    
    /**
     *
     * @ORM\Column(name="codigo_seguranca", type="string", length=10, nullable=true)
     * @AgpAssert\SomenteNumero()
     * @Assert\Length(
     *      min = "3",
     *      max = "4"
     * )
     */
    private $codigoSeguranca;
    
    /**
     *
     * @ORM\Column(type="string", length=10, nullable=false)
     */
    private $mes;
    
    /**
     *
     * @ORM\Column(type="string", length=10, nullable=false)
     */
    private $ano;
    
    /**
     *
     * @ORM\Column(type="string", length=10, nullable=false)
     */
    private $parcelamento;
    
    public function getCodCartao() {
        return $this->codCartao;
    }

    public function setCodCartao($codCartao) {
        $this->codCartao = $codCartao;
    }

    public function getNmCartao() {
        return $this->nmCartao;
    }

    public function setNmCartao($nmCartao) {
        $this->nmCartao = $nmCartao;
    }

    public function getTitular() {
        return $this->titular;
    }

    public function setTitular($titular) {
        $this->titular = $titular;
    }

    public function getCodigoSeguranca() {
        return $this->codigoSeguranca;
    }

    public function setCodigoSeguranca($codigoSeguranca) {
        $this->codigoSeguranca = $codigoSeguranca;
    }

    public function getMes() {
        return $this->mes;
    }

    public function setMes($mes) {
        $this->mes = $mes;
    }

    public function getAno() {
        return $this->ano;
    }

    public function setAno($ano) {
        $this->ano = $ano;
    }
    
    public function getValidadeCielo(){
        return $this->getAno().str_pad($this->getMes(), 2, '0', STR_PAD_LEFT);
    }

    public function getParcelamento(){
        return $this->parcelamento;
    }

    public function setParcelamento($parcelamento) {
        $this->parcelamento = $parcelamento;
    }
    
    public function isAvista(){
        return $this->parcelamento == 1;
    }

}

?>
